package com.dht.xiao.jianye.dayin.ui;


import android.app.Activity;
import android.app.FragmentManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.dht.xiao.jianye.R;
import com.dht.xiao.jianye.dayin.ui.fragment.BlueToothSettingFragment;
import com.dht.xiao.jianye.dayin.ui.fragment.UsbSettingFragment;
import com.dht.xiao.jianye.dayin.ui.fragment.WifiSettingFragment;

/**
 * 通讯设置界面
 * @author zhrjian
 *
 */
public class PrintSettingActivity extends Activity implements OnClickListener {
	private ImageView iv_printsetting_back, iv_setting_bluetooth_topline, iv_setting_wifi_topline
			,iv_setting_usb_topline;// 返回按钮
	private TextView tv_setting_bluetooth_text, tv_setting_wifi_text,tv_setting_usb_text;

	private FragmentManager fragmentManager = null;

	private BlueToothSettingFragment btFragment = null;//蓝牙设置
	private WifiSettingFragment wifiFragment = null;//wifi设置
	private UsbSettingFragment usbFragment = null;//ubs设置

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_printsetting);

		iv_printsetting_back = (ImageView) findViewById(R.id.iv_printsetting_back);
		iv_setting_bluetooth_topline = (ImageView) findViewById(R.id.iv_setting_bluetooth_topline);
		iv_setting_wifi_topline = (ImageView) findViewById(R.id.iv_setting_wifi_topline);
		iv_setting_usb_topline = (ImageView) findViewById(R.id.iv_setting_usb_topline);

		tv_setting_bluetooth_text = (TextView) findViewById(R.id.tv_setting_bluetooth_text);
		tv_setting_wifi_text = (TextView) findViewById(R.id.tv_setting_wifi_text);
		tv_setting_usb_text = (TextView) findViewById(R.id.tv_setting_usb_text);

		iv_printsetting_back.setOnClickListener(this);
		tv_setting_bluetooth_text.setOnClickListener(this);
		tv_setting_wifi_text.setOnClickListener(this);
		tv_setting_usb_text.setOnClickListener(this);

		fragmentManager = getFragmentManager();

		wifiFragment = new WifiSettingFragment();
		btFragment = new BlueToothSettingFragment();
		usbFragment = new UsbSettingFragment();

		iv_setting_wifi_topline.setVisibility(View.VISIBLE);
		iv_setting_bluetooth_topline.setVisibility(View.GONE);
		iv_setting_usb_topline.setVisibility(View.GONE);
		fragmentManager.beginTransaction().add(R.id.fl_fragment_container, wifiFragment).commit();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.iv_printsetting_back:
				finish();
				break;
			case R.id.tv_setting_bluetooth_text:
				iv_setting_bluetooth_topline.setVisibility(View.VISIBLE);
				iv_setting_wifi_topline.setVisibility(View.GONE);
				iv_setting_usb_topline.setVisibility(View.GONE);
				fragmentManager.beginTransaction().replace(R.id.fl_fragment_container, btFragment).commit();
				break;
			case R.id.tv_setting_wifi_text:
				iv_setting_bluetooth_topline.setVisibility(View.GONE);
				iv_setting_usb_topline.setVisibility(View.GONE);
				iv_setting_wifi_topline.setVisibility(View.VISIBLE);
				fragmentManager.beginTransaction().replace(R.id.fl_fragment_container, wifiFragment).commit();
				break;
			case R.id.tv_setting_usb_text:
				iv_setting_bluetooth_topline.setVisibility(View.GONE);
				iv_setting_wifi_topline.setVisibility(View.GONE);
				iv_setting_usb_topline.setVisibility(View.VISIBLE);
				fragmentManager.beginTransaction().replace(R.id.fl_fragment_container,usbFragment).commit();
				break;

		}
	}
}